<?php
class HomesController extends AppController{
	var $uses = array( 'TasksSchedule', 'Schedule', 'Task', 'Project' );
	
	
	function index(){
		$intPersonId = 1;
	
		$listTasks = $this->Task->find( 'all', array( 'fields' => array( 'SUM(estimated_hours) as hours' , 'start_date'), 'conditions' => array( 'Task.person_id' => $intPersonId ), 'group' => array( 'DAYNAME(start_date)' ) ) );
		$listPendingTasks = $this->Task->find( 'all', array( 'fields' => array( 'COUNT(Task.id) as count' , 'end_date', 'Task.name'), 'conditions' => array( 'Task.person_id' => $intPersonId,'progress <' => 100 ), 'group' => array( 'DAY(end_date)' ) ) );
		$listCompletedTasks = $this->Task->find( 'all', array( 'fields' => array( 'COUNT(Task.id) as count' , 'end_date', 'Task.name'), 'conditions' => array( 'Task.person_id' => $intPersonId,'progress' => 100 ), 'group' => array( 'DAY(end_date)' ) ) );
				
		$this->Project->recursive = 2;
		$listProjects = $this->Project->find( 'all', array( 'conditions' => array( 'person_id' => $intPersonId ) ) );
		
		$this->set( compact( 'listTasks', 'listPendingTasks', 'listCompletedTasks', 'listProjects' ) );
	}

}
 ?>